<%-- 
    Document   : showproduct
    Created on : Jul 8, 2011, 5:02:55 PM
    Author     : ThanhToan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@page import="java.util.ArrayList"%>
<%@page import="model.ProductModel"%>
<%@page import="dao.ProductDAO"%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>

        <c:set var="productList" value = '<%= ProductDAO.getAllProductByCateID(request.getParameter("cateID")) %>' scope="session"></c:set>

    </head>
    <body>
        <div id="main_container">
            <!-- S HEAD CONTENT -->
            <jsp:include page="block/header.jsp" />
            <!-- E HEAD CONTENT -->

            <!-- S Top Menu -->
            <jsp:include page="block/top_menu.jsp" />
            <!-- E Top Menu -->

            <!-- S Navigation -->
            <jsp:include page="block/navigation.jsp" />
            <!-- E Navigation -->

            <!-- S Left Menu -->
            <jsp:include page="block/left_menu.jsp" />
            <!-- E Left Menu -->

            <!-- S Body Content -->
            <div class="center_content">
                <br/>
                <form action="ProductController" method="post" style="background: transparent">
                    <c:if test="${not empty param.addtocard}">
                            <b class="msg"> Add success "${param.addtocard}" to Shoppingcard </b>
                    </c:if>
                    <%--<table cellpadding="0" cellspacing="0" border="2" style="background: transparent">
                        <tr>
                            <th bgcolor= '#186fb2'><div class = "div_txtintable1">No.</div></th>
                            <th bgcolor= '#186fb2' ><div class = "div_txtintable1">Image</div></th>
                            <th bgcolor= '#186fb2' ><div class = "div_txtintable1">Product name</div></th>
                            <th bgcolor= '#186fb2' ><div class = "div_txtintable1">Description</div></th>
                            <th bgcolor= '#186fb2' ><div class = "div_txtintable1">Price(USD)</div></th>
                            <c:if test="${not empty sessionScope.userID and (sessionScope.role eq 'Customer' or sessionScope.role eq 'Potential Customer')}" >
                                <th bgcolor= '#186fb2' ><div class = "div_txtintable1"></div></th>
                            </c:if>
                            <c:if test="${not empty sessionScope.userID and sessionScope.role eq 'Dealer'}" >
                                <th bgcolor= '#186fb2' ><div class = "div_txtintable1"></div></th>
                            </c:if>
                        </tr>
                        <c:set var="integer" value="1"></c:set>--%>
                        
                            <%--<tr>
                                <td align="center" width="80px">${integer}</td>
                                <td align="" width="200px" height="200px"><img src="${objProduct.image}" width="200px" height="200px" /></td>
                                <td align="center" width="300px">${objProduct.proName}</td>
                                <td align="center" width="1000px">${objProduct.proDes}</td>
                                <td align="center" width="200px">${objProduct.price}</td>
                                <c:if test="${not empty sessionScope.userID and (sessionScope.role eq 'Customer' or sessionScope.role eq 'Potential Customer')}" >
                                    <td align="center" width="100px">
                                        <a href="ShoppingCardController?action=add&productID=${objProduct.id}"><img src="images/shoppingcart.png" alt="addToShoppingCard" border = "0" width="30px" height="30px"/></a>
                                    </td>
                                </c:if>
                                <c:if test="${not empty sessionScope.userID and sessionScope.role eq 'Dealer'}" >
                                    <td align="center" width="100px">
                                        <a href="productDetails.jsp?proID=${objProduct.id}&proDetails=yes" style="color: green" >Edit</a>
                                    </td>
                                </c:if>
                            </tr>--%>
                    <div class="productList">
                        <ul>
                        <c:forEach var="objProduct" items="${productList}">
                            <li>
                                <div class="productItemHeader">&nbsp;</div>
                                <div class="productItemImage">
                                    <c:choose>
                                        <c:when test="${ not empty objProduct.image }">
                                            <c:forTokens items="${ objProduct.image }" delims="|" var="image" end="0">
                                                <a href="productDetails.jsp?proID=${objProduct.id}&proDetails=yes">
                                                    <img alt="${ objProduct.proName }" src="${objProduct.image}" width="125px" border="0" />
                                                </a>
                                            </c:forTokens>
                                        </c:when>
                                        <c:otherwise>
                                            <a href="productDetails.jsp?proID=${objProduct.id}&proDetails=yes">
                                                <img alt="${objProduct.proName}" src="images/noimg.jpg" width="125px" border="0" />
                                            </a>
                                        </c:otherwise>
                                    </c:choose>
                                </div>
                                <div class="productItemPrice">
                                    <a href=productDetails.jsp?proID=${objProduct.id}&proDetails=yes">${ objProduct.proName }</a>
                                    <br />
                                    Price:<span class="productPrice"><fmt:formatNumber value="${objProduct.price}" type="currency" maxFractionDigits="2" /></span>
                                </div>
                                <div class="productItemAction">
                                    <input type="button" value="Add to cart" name="btnAddCart" class="cart-button"
                                        <c:if test="${not empty sessionScope.userID}" >
                                           onclick='location.href="ShoppingCardController?action=add&productID=${objProduct.id}"' </c:if>/>
                                </div>
                            </li>
                        </c:forEach>
                        </ul>
                    </div>
                            <%--<c:set var="integer" value="${integer+1}"></c:set>--%>
                        
                        <%--<tr>
                            <td></td>
                        </tr>
                    </table>--%>
                </form>
            </div>
            <!-- E Body Content -->

            <!-- S Footer -->
            <jsp:include page="block/footer.jsp" />
            <!-- E Footer -->
        </div>
    </body>
</html>
